Skip to content

[P2] UI: Drive stage Active/Running/Standby badges from live metrics - #1687

Open
BenjaminSRussell wants to merge 1 commit into
mainfrom
token-burner/issue-384
Open

BenjaminSRussell wants to merge 1 commit into
mainfrom
token-burner/issue-384

Conversation

@BenjaminSRussell

Copy link
Copy Markdown
Owner

Closes #384.

What changed

  • Scraping_project/dashboard/format-utils.js: new pure stageBadgeStates(metrics, rates) helper — running when the stage's per-interval rate is > 0 (or work is queued behind it via stage1_urls_queued_total / labelled redis_queue_length), standby when rate ≈ 0 with an empty queue, unknown when the stage's counter series is not exported.
  • Scraping_project/dashboard/app.js: new applyStageBadges(metrics, rates) called from updateDashboard — sets badge text/class on the four Overview stage cards (overview-sN-badge) and drives the four System Health stage rows via setHealthTile. The fetch-failure path already repaints card badges as Unknown/badge-danger; it now also flips the stage health rows to Unknown.
  • Scraping_project/dashboard/index.html: added ids to the four previously anonymous hardcoded badge spans; Stage 3's hardcoded "Running"/badge-success initial state is now neutral "Pending" until the first poll applies the real state.
  • Scraping_project/dashboard/tests/stage-badges.test.js: 7 tests covering idle→active transitions, queue backlog → running, missing/unavailable metrics → unknown, and the app.js/HTML wiring.

Test evidence

node --test Scraping_project/dashboard/tests/: 210/213 pass (was 203/206 on the base commit — the 3 failures in js-budget, error-runbook, and first-run-wizard pre-exist on main and are unrelated). node --check passes on both changed JS files.

Fixes #384

Overview stage cards and the System Health stage rows hardcoded their
badges (Pending/Running/Standby), so a stalled or partially-down stage
still showed Running. Add stageBadgeStates() in format-utils.js and
apply it from updateDashboard via applyStageBadges():

- Running when the stage's per-interval rate is positive, or work is
  queued behind it (stage1_urls_queued_total / redis_queue_length)
- Standby when the rate is ~0 with an empty queue
- Unknown (+badge-danger) when the stage's counter is not exported

The fetch-failure path already repaints card badges as Unknown/danger;
it now also flips the four stage health rows to Unknown. Stage 3's
hardcoded 'Running' initial badge becomes 'Pending' like the others;
the first poll applies the real state.

Tests: tests/stage-badges.test.js covers idle->active transitions,
queue backlog, missing series, and the wiring. node --test
Scraping_project/dashboard/tests/: 210/213 pass; the 3 failures
(js-budget, error-runbook, first-run-wizard) pre-exist on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] UI: Drive stage Active/Running/Standby badges from live metrics

2 participants